﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Isha.Extensions;
using Microsoft.Practices.Unity;
using Isha.Repositories;

namespace Isha.Infrastructure
{
    public class IshaConfig : IContent
    {
        public string SiteName { get; set; }

        public int Home { get; set; }

        public int LanguageID { get; set; }

        public static IshaConfig GetConfiguration()
        {
            IUnityContainer container = DependencyResolver.Current.GetService<IUnityContainer>();

            IshaConfig config = ContentHelper.Deserializer(typeof(IshaConfig),
                                container.Resolve<ContentItemRepository>().Find(p => p.Title == "SiteConfig").ContentXml);

            container.RegisterInstance<IshaConfig>(config);

            return config;
        }

        public bool IsContainable
        {
            get { return true; }
        }
    }
}
